package com.objectdraw.server.commands;

import java.io.IOException;

//import com.objectdraw.server.ObjectDrawServer;
import com.objectdraw.server.data.RequestData;
import com.objectdraw.server.data.ResponseData;

public class DisconnectCommand extends Command {
	private static String myCommand = "disconnect";
	
	@Override
	public void processRequest(RequestData request, ResponseData response) {

		if(myCommand.equalsIgnoreCase(request.getCommand())){
			System.out.println(myCommand+" Command");
//			ObjectDrawServer obj = ObjectDrawServer.getInstance();
//			String uname = request.getParams();
//			try {
//				obj.removeClient(uname).close();
//			} catch (IOException e) {
//				// TODO Auto-generated catch block
//				e.printStackTrace();
//			}
			try {
				request.getClient().close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		//Pass the request on to the next person in line
		if(this.successor != null){
			this.successor.processRequest(request,response);
		}
	}

}
